package com.ruoyi.web.controller.job;
import com.ruoyi.system.entity.JobFlowRecord;
import com.ruoyi.system.service.JobFlowRecordService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;

@RestController
@RequestMapping("jobFlowRecord")
public class JobFlowRecordController {
    /**
     * 服务对象
     */
    @Resource
    private JobFlowRecordService jobFlowRecordService;

    /**
     * 分页查询
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @GetMapping
    public ResponseEntity<Page<JobFlowRecord>> queryByPage(JobFlowRecord jobFlowRecord, PageRequest pageRequest) {
        return ResponseEntity.ok(this.jobFlowRecordService.queryByPage(jobFlowRecord, pageRequest));
    }

    /**
     * 通过主键查询单条数据
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<JobFlowRecord> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.jobFlowRecordService.queryById(id));
    }

    /**
     * 新增数据
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<JobFlowRecord> add(JobFlowRecord jobFlowRecord) {
        return ResponseEntity.ok(this.jobFlowRecordService.insert(jobFlowRecord));
    }

    /**
     * 编辑数据
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<JobFlowRecord> edit(JobFlowRecord jobFlowRecord) {
        return ResponseEntity.ok(this.jobFlowRecordService.update(jobFlowRecord));
    }

    /**
     * 删除数据
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.jobFlowRecordService.deleteById(id));
    }

}

